#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int a[N][N];
int dp[N][N];
int n;
int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= i; ++j) cin >> a[i][j];

  dp[1][1] = a[1][1];
  for (int i = 1; i < n; ++i) {
    for (int j = 1; j <= i; ++j) {
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i + 1][j]);
      dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i + 1][j + 1]);
    }
  }
  cout << *max_element(dp[n] + 1, dp[n] + n + 1) << endl;
}
